package com.loozb.thread6;

/**
 * 使用多线程依次打印1-100
 */
public class Main {


    static class ThreadA implements Runnable {
        private static final Object LOCK = new Object();
        static int value = 0;
        @Override
        public void run() {
            while (value <= 100) {
                synchronized (LOCK) {
                    System.out.println(Thread.currentThread().getName() + ":value:" + value++);
                    LOCK.notify();
                    try {
                        LOCK.wait();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

            }

        }
    }

    public static void main(String[] args) {
        new Thread(new ThreadA(), "偶数").start();
        new Thread(new ThreadA(), "奇数").start();
    }
}
